home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mdishe / forms.bas < prev    next >
BASIC Source File  |  1994-12-29  |  5KB  |  162 lines

  1. ' ********************************************************
  2. '        MDI Standard Application Shell
  3. ' ********************************************************
  4. '
  5. ' SUMMARY
  6. ' -------
  7. ' This file is part of an MDI application "skeleton"
  8. ' created by John Blessing of Leigh Business Enterprises Ltd.
  9. '
  10. ' FEATURES
  11. ' --------
  12. ' Selection of application database.
  13. ' Compact/Repair of database.
  14. ' 'Helptips' on toolbar items.
  15. ' Support for Help files.
  16. ' MDI child forms tiling etc.
  17. ' Error trapping.
  18. ' 'Nag' screen support for shareware authors.
  19. ' Support for 3D dialogs (switched off in design mode
  20. '   to prevent GPFs)
  21. '
  22. ' USE
  23. ' ---
  24. ' You need VB Pro to use this shell, although it could be
  25. ' modified to run under the standard edition.
  26. '
  27. ' You will need to set up some information in APP.BAS,
  28. ' particularly in SetAppInfo().  You will also need to add
  29. ' your own application specific code to this module.
  30. '
  31. ' DISTRIBUTION
  32. ' ------------
  33. ' This program is "FreeWare" and may be used and distributed
  34. ' as you wish.
  35. '
  36. ' It incorporates some ideas/code from other authors and these
  37. ' are acknowledged in the appropriate module.
  38. '
  39. ' We hope that you will find it useful.  If you wish to discuss it
  40. ' then please e-mail us on Compuserve 100444,623.
  41. '
  42. ' ADVERTISEMENT!
  43. ' --------------
  44. ' Are you looking for a helpdesk system? Or does your company
  45. ' want to track and monitor the progress of any work activity?
  46. ' We market a system which could be of interest to you.
  47. '
  48. ' PROGRESS is available for download from the Business section
  49. ' of the Windows Shareware forum on Compuserve
  50. ' (filename PRGRSS10.ZIP).  It's a large program, so in the
  51. ' same section you will also find the help files and
  52. ' documentation as  PRGSSDOC.ZIP which is quicker to download
  53. ' and will give you a good idea of the functionality of PROGRESS.
  54. '
  55. ' Dec 1994
  56. '
  57. 'The KeepOnTop function is taken from the Dec 94
  58. 'Visual Basic Tips and Tricks
  59. '
  60. Option Explicit
  61.  
  62. 'centre a form on the screen or within mdiMain if a child
  63. 'if not an mdi form then call with frmParent = ""
  64. Sub centre (frmChild As Form, frmParent As Form)
  65.     
  66.     If frmChild.WindowState <> 0 Then Exit Sub
  67.  
  68.     If TypeOf frmChild Is MDIForm Then
  69.     'centre on the screen
  70.     frmChild.Move (screen.Width - frmChild.Width) \ 2, (screen.Height - frmChild.Height) \ 2
  71.     ElseIf (frmChild.MDIChild = True) And Not (frmParent Is Nothing) Then
  72.     'centre the mdichild
  73.     frmChild.Move (frmParent.ScaleWidth - frmChild.Width) \ 2, (frmParent.ScaleHeight - frmChild.Height) \ 2
  74.     Else
  75.     'centre on the screen
  76.     frmChild.Move (screen.Width - frmChild.Width) \ 2, (screen.Height - frmChild.Height) \ 2
  77.     End If
  78.     
  79.  
  80. End Sub
  81.  
  82. '======================================================================
  83. 'Form/Module:
  84. '   Forms.bas
  85. '
  86. 'Procedure:
  87. '   CloseAllChildren
  88. '
  89. 'Modifications:
  90. '   23/12/94   JBL     Build
  91. '
  92. 'Description:
  93. '   Closes all but the main MDI form in an application
  94. '======================================================================
  95. Sub CloseAllChildren ()
  96.     'Used for loop through forms
  97.     Dim i, max, temp, abort As Integer
  98.     
  99.    'General Error Handler
  100.     If Not bDesignMode() Then
  101.     On Error GoTo Error_CloseAll
  102.     End If
  103.     
  104.     max = forms.Count - 1
  105.     i = 0
  106.     abort = False
  107.     Do While i <= max
  108.     If TypeOf forms(i) Is MDIForm Then
  109.         'do nothing
  110.         i = i + 1
  111.     Else
  112.         temp = forms.Count
  113.         Unload forms(i)
  114.         If temp = forms.Count Then
  115.         abort = True
  116.         Exit Do
  117.         End If
  118.         max = max - 1
  119.     End If
  120.     Loop
  121.  
  122.     Exit Sub
  123.  
  124. Error_CloseAll:
  125.     'call the generic error handler
  126.     GenErrorHandler "Forms.bas - CloseAllChildren()", Err, Error$
  127.  
  128.     Resume Exit_CloseAll
  129.  
  130. Exit_CloseAll:
  131.         
  132.  
  133. End Sub
  134.  
  135. '*******************************************************
  136. '* Procedure Name: KeepOnTop                         *
  137. '*-----------------------------------------------------*
  138. '* Created: 4/18/94   By: KeepOnTop                    *
  139. '* Modified:          By:                              *
  140. '*=====================================================*
  141. '*Keep form on top. Note that this is switched off if  *
  142. '*form is minimised, so place in resize event as well. *
  143. '*                                                     *
  144. '*                                                     *
  145. '*                                                     *
  146. '*******************************************************
  147. Sub KeepOnTop (F As Form, Mode As Integer)
  148. 'Keep form on top. Note that this is switched off if form is
  149. 'minimised, so place in resize event as well.
  150. Const wFlags = SWP_NOMOVE Or SWP_NOSIZE
  151.  
  152.     
  153.     If Mode Then
  154.     SetWindowPos F.hWnd, HWND_TOPMOST, 0, 0, 0, 0, wFlags
  155.     Else
  156.     SetWindowPos F.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, wFlags
  157.     End If
  158.     
  159.     DoEvents
  160. End Sub
  161.  
  162.